/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 文件类型
 *
 * @author hxloongs
 * @date 2025-01-13
 */
@AllArgsConstructor
@Getter
public enum IsfdMeshModelFileTypeEnum {
    COMPRESSED("compressed", "压缩包文件"),
    DIR("dir", "文件夹"),
    FILE("file", "文件");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdMeshModelFileTypeEnum isfdMeshModelFileTypeEnum = forValue(value);
        if (isfdMeshModelFileTypeEnum == null) {
            return null;
        }
        return isfdMeshModelFileTypeEnum.getDesc();
    }

    public static IsfdMeshModelFileTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdMeshModelFileTypeEnum isfdMeshModelFileTypeEnum : IsfdMeshModelFileTypeEnum.values()) {
            if (isfdMeshModelFileTypeEnum.getValue().equals(value)) {
                return isfdMeshModelFileTypeEnum;
            }
        }
        return null;
    }

    public static IsfdMeshModelFileTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdMeshModelFileTypeEnum isfdMeshModelFileTypeEnum : IsfdMeshModelFileTypeEnum.values()) {
            if (desc.equals(isfdMeshModelFileTypeEnum.getDesc())) {
                return isfdMeshModelFileTypeEnum;
            }
        }
        return null;
    }
}
